package com.example.tencentimdemo.im

/** 消息的具体内容 */
sealed class ImMessageContent {}

data class TextMessage(val text: String) : ImMessageContent()

data class ImageMessage(var thumbUri: String, var originUri: String) : ImMessageContent() {
    var filePath: String = ""

    fun getPath(): String {
        return if (thumbUri.isNotEmpty())
            thumbUri
        else if (originUri.isNotEmpty())
            originUri
        else
            filePath
    }
}

data class VoiceMessage(var fileName: String, val duration: Int, var url:String) : ImMessageContent(){
    var filePath : String = ""
}


data class VideoMessage(var duration: Int, var cover: String, var url: String): ImMessageContent(){
    var coverPath : String = ""
    var fileType : String = ""
    var filePath : String = ""
}

data class CustomMessage(val content: String) : ImMessageContent(){
    private var init = false
    private var contentModel : ImCustomContentModel? = null

    fun getContentModel(): ImCustomContentModel? {
        try {
            if (!init){
//                contentModel = content.fromJsonString()
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return contentModel
    }

}


/** 自定义消息的消息体对应model */
data class ImCustomContentModel(var code : Int , var content : String)